--region NewFile_1.lua
--Author : zhoujibo
--Date   : 2015/5/16
--Desc: 

module('UBBUtil',package.seeall)


--@param autoHeight 根据内容自动适应高度，默认为false
function createAndReplaceNode(node,autoHeight)
    local size = node:getBoundingBox()
    local ret = UBBLabel.createWithParams(size.width,(aotuHeight and nil)or size.height)
    replaceNode(ret,node)
    return ret
end



function createWithScrollView(scrollView)
    local ubblabel = UBBLabel.createWithParams(scrollView:getContainerSize().width)
    scrollView:getContainer():addChild(ubblabel)
    ubblabel:setPositionX(scrollView:getContainerSize().width/2)
    return ubblabel
end

function setStringInScrollView(ubbLabel,text,scrollView)
    if not scrollView then
        scrollView = ubblabel:getParent():getParent()
    end
    local scrolSize = scrollView:getContainerSize()
    ubbLabel:setString(text)
    scrolSize.height = math.max(ubbLabel.totalH,scrolSize.height)
    --重新设置滚动框的大小
    scrollView:setContainerSize(scrolSize)
    --设置文字控件位置，顶
    ubbLabel:setPositionY(scrolSize.height)
    scrollView:relocateContainer()
    scrollView:setContentOffsetToTop()
end

